class Solution {
public:
    string morphic(string s){
        unordered_map<char,int>map;
        string ans="";
        int idx=1;
        for(int i=0;i<s.length();i++){
            if(map.find(s[i])==map.end()){map[s[i]]=idx++;}
            else{ans+=to_string(map[s[i]]);}
        }
        return ans;
    }
    bool isIsomorphic(string s, string t) {
        s=morphic(s);
        t=morphic(t);
        return s==t;
    }
};